package cn.itcast.service.impl;

import cn.itcast.dao.PermissionDao;
import cn.itcast.entity.PageResult;
import cn.itcast.pojo.Permission;
import cn.itcast.service.PermissionServive;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class PermissionServiveImpl implements PermissionServive {
    @Autowired
    private PermissionDao permissionDao;

    @Override
    public PageResult pageQuery(Integer currentPage, Integer pageSize, String queryString) {
        //分页查询权限管理
        PageHelper.startPage(currentPage, pageSize);
        Page<Permission> page = permissionDao.selectByCondition(queryString);
        return new PageResult(page.getTotal(), page.getResult());
    }

    @Override
    public Permission findById(Integer id) {
        //根据ID查询权限详情
        Permission permission = permissionDao.findById(id);
        return permission;
    }

    @Override
    public void updatePermission(Permission permission) {
        // 修改权限信息
        permissionDao.updatePermission(permission);
    }

    @Override
    public void addPermission(Permission permission) {
        // 新增权限信息
        permissionDao.addPermission(permission);
    }

    @Override
    public void deletePermission(Integer id) {
        // 删除权限信息
        permissionDao.deletePermission(id);
    }

    @Override
    public List<Permission> findMenuPermission(Integer[] integers) {
        return permissionDao.findMenuPermission(integers);
    }

    @Override
    public List<Permission> findAll() {
        List<Permission> list = permissionDao.findAll();
        return list;
    }

    @Override
    public Permission findByIdPermission(Integer id) {
        return null;
    }


}







